import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_audit_app/res/strings.dart';
import 'package:flutter_audit_app/res/styles.dart';
import 'package:flutter_audit_app/ui/home/views/cost_stat_page.dart';
import 'package:flutter_audit_app/ui/home/views/past_violations_page.dart';
import 'package:flutter_audit_app/ui/home/views/person_annual_project_page.dart';
import 'package:flutter_audit_app/ui/home/views/person_base_info_page.dart';
import 'package:flutter_audit_app/ui/home/views/person_insured_info_page.dart';
import 'package:flutter_audit_app/ui/home/views/person_medical_settle_page.dart';
import 'package:flutter_audit_app/ui/home/views/person_medical_track_page.dart';
import 'package:flutter_audit_app/ui/home/views/recent_stat_page.dart';
import 'package:flutter_audit_app/widgets/my_app_bar.dart';

///  项目名称：flutter_audit_app
///  Created by leon on 2020/08/22 .

///  个人信息查询详情
///
class PersonInfoQueryDetailPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => _PersonInfoQueryDetailState();
}

class _PersonInfoQueryDetailState extends State<PersonInfoQueryDetailPage>
    with SingleTickerProviderStateMixin {
  final tabs = [
    Strings.basicInfoTxt,
    Strings.pSocialInfoTxt,
    Strings.pMedicalTreatTrackTxt,
    Strings.recentStatTxt,
    Strings.costStatTxt,
    Strings.previousViolateTxt,
    Strings.pMedicalSettleTxt,
    Strings.pYearProjectTotalTxt,
  ];

  TabController _tabController;

  @override
  void initState() {
    super.initState();
    _tabController = TabController(
      vsync: ScrollableState(),
      length: tabs.length,
    );
  }

  @override
  void dispose() {
    _tabController.dispose();
    super.dispose();
  }

  ///Flutter Incorrect use of ParentDataWidget
  ///Expanded、Flexible只在Row、Column等组件内，不在其他组件内使用。
  @override
  Widget build(BuildContext context) {
    return AnnotatedRegion<SystemUiOverlayStyle>(
      value: SystemUiOverlayStyle.dark,
      child: Scaffold(
        appBar: MyAppBar(
          title: TabBar(
            // indicatorWeight: 3,
            isScrollable: true,
            indicatorColor: Colors.transparent,
            labelColor: Colors.white,
            labelStyle: TextStyles.textBold16,
            unselectedLabelStyle: TextStyles.textSize14,
            indicatorSize: TabBarIndicatorSize.label,
            controller: _tabController,
            tabs: [
              Tab(text: tabs[0]),
              Tab(text: tabs[1]),
              Tab(text: tabs[2]),
              Tab(text: tabs[3]),
              Tab(text: tabs[4]),
              Tab(text: tabs[5]),
              Tab(text: tabs[6]),
              Tab(text: tabs[7]),
            ],
          ),
        ),
        body: TabBarView(
          controller: _tabController,
          physics: NeverScrollableScrollPhysics(),
          children: [
            PersonBaseInfoPage(),
            PersonInsuredInfoPage(),
            PersonMedicalTrackPage(),
            RecentStatPage(),
            CostStatPage(),
            PastViolationsPage(),
            PersonMedicalSettlePage(),
            PersonAnnualProjectPage(),
          ],
        ),
      ),
    );
  }
}
